/*
 * This file is part of aion-engine <aion-engine.com>
 *
 * aion-engine is private software: you can redistribute it and or modify
 * it under the terms of the GNU Lesser Public License as published by
 * the Private Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aion-engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser Public License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License
 * along with aion-engine.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionengine.gameserver.model.team2.group;

import com.aionengine.gameserver.model.gameobjects.Pet;
import com.aionengine.gameserver.model.gameobjects.player.Player;
import com.aionengine.gameserver.model.templates.pet.PetFunctionType;
import com.google.common.base.Predicate;

/**
 * @author ATracer
 */
public class PlayerFilters {

    public static final Predicate<Player> ONLINE = new Predicate<Player>() {

        @Override
        public boolean apply(Player member) {
            return member.isOnline();
        }
    };

    public static final class MentorSuiteFilter implements Predicate<Player> {

        private final Player player;

        public MentorSuiteFilter(Player player) {
            this.player = player;
        }

        @Override
        public boolean apply(Player member) {
            return member.getLevel() + 9 < player.getLevel();
        }

    }

    public static final class SameInstanceFilter implements Predicate<Player> {

        private final Player player;

        public SameInstanceFilter(Player player) {
            this.player = player;
        }

        @Override
        public boolean apply(Player member) {
            return member.getInstanceId() == player.getInstanceId();
        }

    }

    public static final Predicate<Player> HAS_LOOT_PET = new Predicate<Player>() {

        @Override
        public boolean apply(Player member) {
            Pet pet = member.getPet();
            if (pet == null)
                return false;
            return pet.getPetTemplate().getPetFunction(PetFunctionType.LOOT) != null;
        }
    };

    public static final class ExcludePlayerFilter implements Predicate<Player> {

        private final Player player;

        public ExcludePlayerFilter(Player player) {
            this.player = player;
        }

        @Override
        public boolean apply(Player member) {
            return !player.getObjectId().equals(member.getObjectId());
        }

    }
}
